package cn.tedu._04mvcboot02.exception;

import cn.tedu._04mvcboot02.commom.response.JsonResult;
import cn.tedu._04mvcboot02.commom.response.StatusCode;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

@Slf4j
@RestControllerAdvice
public class GlobalExceptionHandler {
    @ExceptionHandler
    public JsonResult doHandleRuntimeException(RuntimeException ex){
        String message = ex.getMessage();
        log.debug("父类---------"+message);
        return new JsonResult(StatusCode.FAILED,message);
    }
    @ExceptionHandler
    public JsonResult doHandleIllegalArgumentException(IllegalArgumentException ex){
        String message = ex.getMessage();
        log.debug("子类---------"+message);
        return new JsonResult(StatusCode.FAILED,message);
    }
    @ExceptionHandler
    public JsonResult doHandleTHrowable(Throwable ex){
       return new JsonResult(88888,"程序运行时程序了Throwable异常");


    }
}
